/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.tiberio.movil.activity;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;
import com.tiberio.movil.entity.ForoEntity;
import com.tiberio.movil.servicio.ServicioHttp;
import java.util.ArrayList;

/**
 *
 * @author Chema
 */


public class ForoListActivity extends ListActivity
{
    ArrayList<ForoEntity> foros;
    
    @Override
    public void onCreate(Bundle icicle)
    {
        super.onCreate(icicle);
        ServicioHttp servicioHttp = ServicioHttp.getInstance();
        
        foros = servicioHttp.recuperarForos();
        if(!foros.isEmpty())
            setListAdapter(new ArrayAdapter(this, android.R.layout.simple_list_item_1, android.R.id.text1, foros));
    }
    
    @Override
    protected void onListItemClick(ListView l, View v, int position, long id)
    {
	Intent  myIntent = new Intent(this, HilosListActivity.class);
        ForoEntity foroSeleccionado = foros.get(position);
        
        int idForo = foroSeleccionado.getId();
        myIntent.putExtra("idForo", idForo);
        startActivity(myIntent);
		
                
    }


}
